package com.starry.home.logic.network

import com.starry.core.constant.GlobalConfig
import com.starry.core.logic.SharedOkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory


/**
 * @ClassName ServiceCreator
 * @Description 整个APP的网络请求接口配置
 * @Author jiangyuntao
 * @Data 2023/5/20 14:43
 * @Version 1.0
 */
object ServiceCreator {

    private val retrofit: Retrofit by lazy {

        Retrofit.Builder()
            .baseUrl(GlobalConfig.getBaseServerUrl())
            .addConverterFactory(GsonConverterFactory.create())
            .client(SharedOkHttpClient.getClient())
            .build()
    }

    inline fun <reified T> create(): T = create(T::class.java)

    fun <T> create(serviceClass: Class<T>): T = retrofit.create(serviceClass)

}